package com.dy.controller;

import com.dy.bean.Sugar;
import com.dy.bean.SugarTwo;
import com.dy.service.SuagrService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0613
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/13 19:09
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SuagrService suagrService;

    @RequestMapping("/ListYd")
    public Map showYd() {
        Map map = new HashMap<>();
        List<Sugar> sugars = suagrService.showYd();
        map.put("status", 0);
        map.put("data", sugars);
        return map;
    }

    @RequestMapping("/ListXd")
    public Map showXd() {
        return SugarUtil.getPieData(suagrService.showXd());
    }

    @RequestMapping("/showJg")
    public String showJg() {
        List<SugarTwo> sugarTwos = suagrService.showJg();
        List list = new ArrayList<>();
        list.add("机构名称");
        list.add("完成里程");
        list.add("完成次数");
        list.add("完成时长");
        list.add("每次平均时长");
        list.add("每次平均里程");
        return SugarUtil.getTablePlayData(list,sugarTwos);
    }
}
